//
//  PendApprovalNewAddTableViewCell.m
//  ZJControlsClass
//
//  Created by mac on 2024/12/10.
//

#import "PendApprovalNewAddTableViewCell.h"

@implementation PendApprovalNewAddTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self configUI];
    }
    return self;
}



-(void)changeCellValueWithType:(NSInteger)isType Paramer:(NSMutableDictionary *)dic{
    if (isType == 1){
        
        self.titleLabel.text = @"付款";
        self.leftOnetLabel.text = @"缴费金额";
        self.leftTwoLabel.text = @"缴费状态";
        self.leftThreeLabel.text = @"缴费时间";
        
        self.rightOneLabel.text = [NSString stringWithFormat:@"￥%@",dic[@"formData"][@"pay_amount"]];
        
        NSString * status;
        if ([dic[@"formData"][@"pay_status"] intValue] == 0){
            status = @"未支付";
        }else if ([dic[@"formData"][@"pay_status"] intValue] == 10){
            status = @"已确认收款";
        }else if ([dic[@"formData"][@"pay_status"] intValue] == 20){
            status = @"已退款";
        }else if ([dic[@"formData"][@"pay_status"] intValue] == 30){
            status = @"支付关闭";
        }
        self.rightTwoLabel.text = [NSString stringWithFormat:@"%@",status];
        self.rightThreeLabel.text = [NSString stringWithFormat:@"%@",dic[@"formData"][@"pay_time"]];
        
    }else if (isType == 2){
        self.titleLabel.text = @"培训";
        self.leftOnetLabel.text = @"培训课程";
        self.leftTwoLabel.text = @"培训时长";
        self.leftThreeLabel.text = @"完成时间";
        
        self.rightOneLabel.text = [NSString stringWithFormat:@"%@节",dic[@"formData"][@"NUM"]];
        
        NSInteger seconds = [dic[@"formData"][@"TIME"] integerValue];
        NSInteger hours = seconds / 3600;
        NSInteger minutes = (seconds % 3600) / 60;
        NSInteger remainingSeconds = seconds % 60;
        
        NSString *timeString;
        if (hours > 0) {
            timeString = [NSString stringWithFormat:@"%ld小时%ld分%ld秒", (long)hours, (long)minutes, (long)remainingSeconds];
        } else if (minutes > 0) {
            timeString = [NSString stringWithFormat:@"%ld分%ld秒", (long)minutes, (long)remainingSeconds]; 
        } else {
            timeString = [NSString stringWithFormat:@"%ld秒", (long)remainingSeconds];
        }
        
        self.rightTwoLabel.text = timeString;
        self.rightThreeLabel.text = [NSString stringWithFormat:@"%@",dic[@"formData"][@"completeTime"]];
        
    }else if (isType == 3){
        self.titleLabel.text = @"考试";
        self.leftOnetLabel.text = @"考试成绩";
        self.leftTwoLabel.text = @"考试结果";
        self.leftThreeLabel.text = @"考试时间";
        
        self.rightOneLabel.text = [NSString stringWithFormat:@"%@分",dic[@"formData"][@"totalScore"]];
        
        NSString * str;
        if ([dic[@"formData"][@"isPassed"] boolValue]){
            str = @"合格";
        }else{
            str = @"不合格";
        }
        self.rightTwoLabel.text = [NSString stringWithFormat:@"%@",str];
        self.rightThreeLabel.text = [NSString stringWithFormat:@"%@",dic[@"formData"][@"examTime"]];
        
    }
    
}


- (void)configUI {
    
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.leftOnetLabel];
    [self.contentView addSubview:self.rightOneLabel];
    [self.contentView addSubview:self.leftTwoLabel];
    [self.contentView addSubview:self.rightTwoLabel];
    [self.contentView addSubview:self.leftThreeLabel];
    [self.contentView addSubview:self.rightThreeLabel];
    [self.contentView addSubview:self.V];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.contentView).offset(-15);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
    }];
    
    [self.leftOnetLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom);
        make.left.equalTo(self.contentView).offset(15);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
    }];
    
    [self.rightOneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftOnetLabel);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
        make.right.equalTo(self.contentView).offset(-15);
    }];
    
    [self.leftTwoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftOnetLabel.mas_bottom);
        make.left.equalTo(self.contentView).offset(15);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
    }];
    
    [self.rightTwoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftTwoLabel);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
        make.right.equalTo(self.contentView).offset(-15);
    }];
    
    [self.leftThreeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftTwoLabel.mas_bottom);
        make.left.equalTo(self.contentView).offset(15);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
    }];
    
    [self.rightThreeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftThreeLabel);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(45)));
        make.right.equalTo(self.contentView).offset(-15);
    }];
    
    [self.V mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftOnetLabel.mas_left);
        make.right.equalTo(self.rightOneLabel.mas_right);
        make.top.equalTo(self.leftThreeLabel.mas_bottom);
        make.height.equalTo(@(1));
    }];
    
}

#pragma mark - Lazy Load
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:16 weight:0.3];
        _titleLabel.textColor = [UIColor blackColor];
    }
    return _titleLabel;
}

- (UILabel *)leftOnetLabel {
    if (!_leftOnetLabel) {
        _leftOnetLabel = [[UILabel alloc] init];
        _leftOnetLabel.font = FONT14;
        _leftOnetLabel.textColor = [UIColor grayColor];
    }
    return _leftOnetLabel;
}

- (UILabel *)rightOneLabel {
    if (!_rightOneLabel) {
        _rightOneLabel = [[UILabel alloc] init];
        _rightOneLabel.font = [UIFont systemFontOfSize:14];
        _rightOneLabel.textColor = [UIColor blackColor];
    }
    return _rightOneLabel;
}

- (UILabel *)leftTwoLabel {
    if (!_leftTwoLabel) {
        _leftTwoLabel = [[UILabel alloc] init];
        _leftTwoLabel.font = [UIFont systemFontOfSize:14];
        _leftTwoLabel.textColor = [UIColor grayColor];
    }
    return _leftTwoLabel;
}

- (UILabel *)rightTwoLabel {
    if (!_rightTwoLabel) {
        _rightTwoLabel = [[UILabel alloc] init];
        _rightTwoLabel.font = [UIFont systemFontOfSize:14];
        _rightTwoLabel.textColor = [UIColor blackColor];
    }
    return _rightTwoLabel;
}

- (UILabel *)leftThreeLabel {
    if (!_leftThreeLabel) {
        _leftThreeLabel = [[UILabel alloc] init];
        _leftThreeLabel.font = [UIFont systemFontOfSize:14];
        _leftThreeLabel.textColor = [UIColor grayColor];
    }
    return _leftThreeLabel;
}

- (UILabel *)rightThreeLabel {
    if (!_rightThreeLabel) {
        _rightThreeLabel = [[UILabel alloc] init];
        _rightThreeLabel.font = [UIFont systemFontOfSize:14];
        _rightThreeLabel.textColor = [UIColor blackColor];
    }
    return _rightThreeLabel;
}

-(UIView *)V{
    if (!_V){
        _V = [UIView new];
        _V.backgroundColor = COLOR_RGB(244, 244, 244);
    }
    return _V;
}


@end
